package com.waldamartin.android.mobileapplicationspairsapp.control;

import java.util.ArrayList;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.GridLayout.LayoutParams;

/**
 * Class to deal with the cards set overview
 * 
 * @author Martin
 */
public class SetGridViewAdapter extends BaseAdapter
{
	private ArrayList<Integer> arrayList;
	
	/**
	 * Remember associated set
	 * 
	 * @param arrayList Card set
	 */
	public SetGridViewAdapter(ArrayList<Integer> arrayList)
	{
		this.arrayList = arrayList;
	}
	
	@Override
	public int getCount()
	{
		return arrayList.size();
	}

	@Override
	public Object getItem(int position)
	{
		return null;
	}

	@Override
	public long getItemId(int position)
	{
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{		
		// Set entry
		ImageView imageView;
        if (convertView == null) 
        {  
        	// if it's not recycled, initialize some attributes
        	imageView = new ImageView(parent.getContext());
            imageView.setLayoutParams(new GridView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(1, 1, 1, 1);
        } 
        else 
        {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(arrayList.get(position));
        return imageView;

	}
	
}
